package com.zsd.android.dblib.enums;

import com.zsd.android.dblib.bean.User;
import com.zsd.android.dblib.db.BaseDao;
import com.zsd.android.dblib.db.BaseDaoFactory;
import com.zsd.android.dblib.db.UserDao;

import java.io.File;

public enum PrivateDatabaseEnums {

    database("");

    private String value;

    PrivateDatabaseEnums(String value) {
    }

    public String getValue() {
        UserDao userDao = BaseDaoFactory.getInstance().getBaseDao(UserDao.class, User.class);
        if (userDao != null) {
            User user = userDao.getCurrentUser();
            if (user != null) {
                File file = new File("data/data/com.zsd.android.dblib/");
                if (!file.exists()) {
                    file.mkdirs();
                }
                return file.getAbsolutePath() + File.separator + "u_" + user.getId() + "_private.db";
            }
        }
        return null;
    }
}
